<?php

/**
 * This is the model class for table "operatingfeatures".
 *
 * The followings are the available columns in table 'operatingfeatures':
 * @property integer $Id
 * @property integer $FireBrigadeOrganization
 * @property integer $FireSafeteySeminar
 * @property integer $EmployeesTrainedInEmergencyProcedures
 * @property integer $FireOrEvacuationDrill
 * @property string $Drill01
 * @property string $Drill02
 * @property string $Drill03
 * @property string $Drill04
 * @property string $DateLastConducted
 * @property integer $Establishment_Id
 *
 * The followings are the available model relations:
 * @property Establishments $establishment
 */
class Operatingfeatures extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'operatingfeatures';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('FireBrigadeOrganization, FireSafeteySeminar, EmployeesTrainedInEmergencyProcedures, FireOrEvacuationDrill, Establishment_Id', 'numerical', 'integerOnly'=>true),
			array('Drill01, Drill02, Drill03, Drill04', 'length', 'max'=>100),
			array('DateLastConducted', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('Id, FireBrigadeOrganization, FireSafeteySeminar, EmployeesTrainedInEmergencyProcedures, FireOrEvacuationDrill, Drill01, Drill02, Drill03, Drill04, DateLastConducted, Establishment_Id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'establishment' => array(self::BELONGS_TO, 'Establishments', 'Establishment_Id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id' => 'ID',
			'FireBrigadeOrganization' => 'Fire Brigade Organization',
			'FireSafeteySeminar' => 'Fire Safetey Seminar',
			'EmployeesTrainedInEmergencyProcedures' => 'Employees Trained In Emergency Procedures',
			'FireOrEvacuationDrill' => 'Fire Or Evacuation Drill',
			'Drill01' => 'Drill01',
			'Drill02' => 'Drill02',
			'Drill03' => 'Drill03',
			'Drill04' => 'Drill04',
			'DateLastConducted' => 'Date Last Conducted',
			'Establishment_Id' => 'Establishment',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id',$this->Id);
		$criteria->compare('FireBrigadeOrganization',$this->FireBrigadeOrganization);
		$criteria->compare('FireSafeteySeminar',$this->FireSafeteySeminar);
		$criteria->compare('EmployeesTrainedInEmergencyProcedures',$this->EmployeesTrainedInEmergencyProcedures);
		$criteria->compare('FireOrEvacuationDrill',$this->FireOrEvacuationDrill);
		$criteria->compare('Drill01',$this->Drill01,true);
		$criteria->compare('Drill02',$this->Drill02,true);
		$criteria->compare('Drill03',$this->Drill03,true);
		$criteria->compare('Drill04',$this->Drill04,true);
		$criteria->compare('DateLastConducted',$this->DateLastConducted,true);
		$criteria->compare('Establishment_Id',$this->Establishment_Id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Operatingfeatures the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
